import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '系统',
    align: "center",
    dataIndex: 'projectSystemId_dictText'
  },
  {
    title: '漏洞名称',
    align: "center",
    dataIndex: 'loopholeName'
  },
  {
    title: '漏洞级别',
    align: "center",
    sorter: true,
    dataIndex: 'loopholeLevel_dictText'
  },
  {
    title: '漏洞类型',
    align: "center",
    sorter: true,
    dataIndex: 'loopholeStyle_dictText'
  },
  {
    title: '安全测类型',
    align: "center",
    sorter: true,
    dataIndex: 'securityTestStyle_dictText'
  },
  {
    title: '漏洞状态',
    align: "center",
    sorter: true,
    dataIndex: 'loopholeStatus_dictText'
  },
  {
    title: '处理人',
    align: "center",
    dataIndex: 'processedBy_dictText'
  },
  {
    title: '发现人',
    align: "center",
    dataIndex: 'defectBy'
  },
  {
    title: '修复期限',
    align: "center",
    dataIndex: 'repairPeriod',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建日期',
    align: "center",
    sorter: true,
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新日期',
    align: "center",
    sorter: true,
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "系统",
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "漏洞名称",
    field: 'loopholeName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "漏洞级别",
    field: 'loopholeLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_level"
    },
    //colProps: {span: 6},
  },
  {
    label: "漏洞类型",
    field: 'loopholeStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_style"
    },
    //colProps: {span: 6},
  },
  {
    label: "安全测类型",
    field: 'securityTestStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "security_test_style"
    },
    //colProps: {span: 6},
  },
  {
    label: "漏洞状态",
    field: 'loopholeStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "处理人",
    field: 'processedBy',
    component: 'JSelectUserByDept',
    //colProps: {span: 6},
  },
  {
    label: "发现人",
    field: 'defectBy',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "漏洞描述",
    field: 'loopholeDesc',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "修复期限",
    field: 'repairPeriod',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "创建日期",
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
    },
    //colProps: {span: 6},
  },
  {
    label: "更新日期",
    field: 'updateTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '系统',
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入系统!'},
             ];
    },
  },
  {
    label: '漏洞名称',
    field: 'loopholeName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入漏洞名称!'},
             ];
    },
  },
  {
    label: '漏洞级别',
    field: 'loopholeLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_level"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入漏洞级别!'},
             ];
    },
  },
  {
    label: '漏洞类型',
    field: 'loopholeStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_style"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入漏洞类型!'},
             ];
    },
  },
  {
    label: '安全测类型',
    field: 'securityTestStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "security_test_style"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入安全测类型!'},
             ];
    },
  },
  {
    label: '漏洞状态',
    field: 'loopholeStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "loophole_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入漏洞状态!'},
             ];
    },
  },
  {
    label: '处理人',
    field: 'processedBy',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入处理人!'},
             ];
    },
  },
  {
    label: '漏洞描述',
    field: 'loopholeDesc',
    component: 'JEditor',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入漏洞描述!'},
             ];
    },
  },
  {
    label: '修复建议',
    field: 'repairSuggestion',
    component: 'JEditor',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入修复建议!'},
             ];
    },
  },
  {
    label: '修复期限',
    field: 'repairPeriod',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入修复期限!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: 'tm_project', dictCode: 'id', dictText: 'project_name',},
  projectSystemId: {title: '系统',order: 1,view: 'sel_search', type: 'string',dictTable: 'tm_project_system', dictCode: 'id', dictText: 'system_name',},
  loopholeName: {title: '漏洞名称',order: 2,view: 'text', type: 'string',},
  loopholeLevel: {title: '漏洞级别',order: 3,view: 'list', type: 'string',dictCode: 'loophole_level',},
  loopholeStyle: {title: '漏洞类型',order: 4,view: 'list', type: 'string',dictCode: 'loophole_style',},
  securityTestStyle: {title: '安全测类型',order: 5,view: 'list', type: 'string',dictCode: 'security_test_style',},
  loopholeStatus: {title: '漏洞状态',order: 6,view: 'list', type: 'string',dictCode: 'loophole_status',},
  processedBy: {title: '处理人',order: 7,view: 'sel_user', type: 'string',},
  defectBy: {title: '发现人',order: 8,view: 'text', type: 'string',},
  repairPeriod: {title: '修复期限',order: 11,view: 'date', type: 'string',},
  createBy: {title: '创建人',order: 12,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 13,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 14,view: 'text', type: 'string',},
  updateTime: {title: '更新日期',order: 15,view: 'datetime', type: 'string',},
};
